* Mechanisms_SummaryStats
** Goal: write summary stats table for mechanisms section
** Beatrice Lee
** Date Created: 2023-06-27 
** Last Updated: 2024-07-09 // bal

*** load dataset ***
*cd "$Data/Final"
*use state_elections_finance_panel_df_labeled_may2024_final, clear

cd "$Data/Processing"
use state_elections_panel_df5_20240709, clear

***** Summary Stats Table 

* panel a: pandemic sample (camp finance, state leg)
eststo clear

estpost tabstat chng_log_inc_rcpts_EYmatch chng_log_prv_inc_rcpts_EYmtch chng_log_top_ninc_rcpts_EYmtch chng_log_prv_tninc_rcpts_EYmtch EY_switch_dummy state_sen_ctrl_gub_pty lag_state_sen_ctrl_gub_pty state_house_ctrl_gub_pty lag_state_house_ctrl_gub_pty state_sen_ctrl_sen_pty lag_state_sen_ctrl_sen_pty state_house_ctrl_sen_pty lag_state_house_ctrl_sen_pty if (year >= 2020 & year <= 2022), c(stat) stat(mean sd min max n)

cd "$Results/"
#delimit ;
esttab using "mech_sumstats1_20240709.tex",
 replace ///Replace file if already exists
 cells("mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))") ///Which Stats to Output
 nonumber ///Do not put numbers below column titles
 nomtitle ///This option mainly for regression tables
 booktabs ///Top, Mid, Bottom Rule
 noobs ///We don't need observation counts because count is N
 title("Summary Statistics\label{tab1}") ///Latex number this for us
 collabels("Mean" "SD" "Min" "Max" "N") /// Name of each column
 addnote("TKTKTK") ///Note below table
 coeflabels(chng_log_inc_rcpts_EYmatch "Change in Log Inc. Party Receipts" chng_log_prv_inc_rcpts_EYmtch "Change in Log Inc. Party Receipts (Prev. Election)" chng_log_top_ninc_rcpts_EYmtch "Change in Challenger Party Receipts" chng_log_prv_tninc_rcpts_EYmtch "Change in Challenger Party Receipts (Prev. Election)" EY_switch_dummy "Outcome-Control Election Year Dummy" state_sen_ctrl_gub_pty "Share State Sen. Controlled by Inc. Gov's Party" lag_state_sen_ctrl_gub_pty "Share State Sen. Controlled by Inc. Gov's Party (Prev. Election)" state_house_ctrl_gub_pty "Share State House Controlled by Inc. Gov's Party" lag_state_house_ctrl_gub_pty "Share State House Controlled by Inc. Gov's Party (Prev. Election)" state_sen_ctrl_sen_pty "Share State Sen. Controlled by Inc. Sen's Party" lag_state_sen_ctrl_sen_pty "Share State Sen. Controlled by Inc. Sen's Party (Prev. Election)" state_house_ctrl_sen_pty "Share State House Controlled by Inc. Sen's Party" lag_state_house_ctrl_sen_pty "Share State House Controlled by Inc. Sen's Party (Prev. Election)") ///Label variables right in command
;

* panel a: pandemic sample (voter turnout)
*cd "$Data/Final"
*use state_elections_finance_panel_df_labeled, clear

* panel a: pandemic sample (additional statewide elections)
eststo clear 

estpost tabstat inc_turnout_vep inc_turnout_vep_prev top_nic_turnout_vep top_nic_turnout_vep_prev total_turnout_vep total_turnout_vep_prev if (year >= 2020 & year <= 2022), c(stat) stat(mean sd min max n)

cd "$Results/"
#delimit ;
esttab using "mech_sumstats2_20240709.tex",
 replace ///Replace file if already exists
 cells("mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))") ///Which Stats to Output
 nonumber ///Do not put numbers below column titles
 nomtitle ///This option mainly for regression tables
 booktabs ///Top, Mid, Bottom Rule
 noobs ///We don't need observation counts because count is N
 title("Summary Statistics\label{tab1}") ///Latex number this for us
 collabels("Mean" "SD" "Min" "Max" "N") /// Name of each column
 addnote("TKTKTK") ///Note below table
 coeflabels(inc_turnout_vep "Inc. Party Votes / VEP" top_nic_turnout_vep "Challenger Party Votes / VEP"  total_turnout_vep "Total Votes / VEP" inc_turnout_vep_prev "Inc. Party Votes / VEP (Prev. Election)" top_nic_turnout_vep_prev "Challenger Party Votes / VEP (Prev. Election)" total_turnout_vep_prev "Total Votes / VEP (Prev. Election)"); ///Label variables right in command
 
 * panel a: pandemic sample (additional swide election)
cd "$Data/Processing"
use additional_statewide_elect_20240709, clear

* panel a: pandemic sample (additional statewide elections)
eststo clear 

estpost tabstat margin_ctrl_gub_pty margin_ctrl_gub_pty_prev margin_inc_pty margin_inc_pty_prev if (year >= 2020 & year <= 2022), c(stat) stat(mean sd min max n)

cd "$Results/"
#delimit ;
esttab using "mech_sumstats3_20240709.tex",
 replace ///Replace file if already exists
 cells("mean(fmt(3)) sd(fmt(3)) min(fmt(3)) max(fmt(3)) count(fmt(0))") ///Which Stats to Output
 nonumber ///Do not put numbers below column titles
 nomtitle ///This option mainly for regression tables
 booktabs ///Top, Mid, Bottom Rule
 noobs ///We don't need observation counts because count is N
 title("Summary Statistics\label{tab1}") ///Latex number this for us
 collabels("Mean" "SD" "Min" "Max" "N") /// Name of each column
 addnote("TKTKTK") ///Note below table
 coeflabels(margin_ctrl_gub_pty "Margin of Victory, Inc. Governor's Party"
 margin_ctrl_gub_pty_prev "Margin of Victory, Inc. Governor's Party (Prev. Election)"
 margin_inc_pty "Margin of Victory, Incumbent's Party"
 margin_inc_pty_prev "Margin of Victory, Incumbent's Party (Prev. Election)"); ///Label variables right in command
 
 
 

 
 


